﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  >

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../Brushes.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <Style TargetType="{x:Type TreeView}">
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TreeView}">
          <Grid>
            <Border x:Name="Border" Background="{DynamicResource ControlBackgroundBrush}" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="3,3,3,3">
              <ScrollViewer Style="{DynamicResource NuclearScrollViewer}" Focusable="False" Padding="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="False" Foreground="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}">
                <ItemsPresenter />
              </ScrollViewer>
            </Border>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="NuclearTreeViewItemToggleButton" d:IsControlPart="True" TargetType="{x:Type ToggleButton}">
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid Width="15" Height="13">
            <Path Visibility="Collapsed" HorizontalAlignment="Left" Margin="1,1,1,1" x:Name="IsExpandedPath" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 4 L 8 4 L 4 8 Z" />
            <Path HorizontalAlignment="Left" Margin="1,1,1,1" x:Name="ExpandPath" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 4 0 L 8 4 L 4 8 Z" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="True">
              <Setter Property="Visibility" Value="Visible" TargetName="IsExpandedPath" />
              <Setter Property="Visibility" Value="Collapsed" TargetName="ExpandPath" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style d:IsControlPart="True" TargetType="{x:Type TreeViewItem}">
    <Style.Triggers>
      <Trigger Property="IsSelected" Value="True">
        <Setter Property="Foreground">
          <Setter.Value>
            <SolidColorBrush Color="{DynamicResource BlackColor}"/>
          </Setter.Value>
        </Setter>
      </Trigger>
    </Style.Triggers>

    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
    <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
    <Setter Property="Padding" Value="1,0,0,0" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TreeViewItem}">
          <ControlTemplate.Resources>
            <Storyboard x:Key="HoverOn">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="HoverOff">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="SelectedOn">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SelectionBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="SelectedOff">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SelectionBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
          </ControlTemplate.Resources>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition MinWidth="19" Width="Auto" />
              <ColumnDefinition Width="Auto" />
              <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto" />
              <RowDefinition />
            </Grid.RowDefinitions>
            <ToggleButton x:Name="Expander" Style="{DynamicResource NuclearTreeViewItemToggleButton}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" />
            <Border Grid.Column="1" x:Name="Selection_Border" BorderThickness="1,1,1,1" CornerRadius="3,3,3,3">
              <Grid Width="Auto" Height="Auto">
                <Border x:Name="MainBorder" Opacity="0.25" Background="{DynamicResource NormalBrush}" CornerRadius="2,2,2,2"/>
                <Border x:Name="SelectionBorder" Opacity="0" Background="{DynamicResource SelectedBackgroundBrush}" CornerRadius="2,2,2,2"/>
                <Border x:Name="HoverBorder" Opacity="0" Background="{DynamicResource NormalBrush}" CornerRadius="2,2,2,2"/>
                <ContentPresenter x:Name="PART_Header" ContentSource="Header" d:LayoutOverrides="Width" Height="Auto" Margin="2,0,2,0" />
              </Grid>
            </Border>
            <ItemsPresenter Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" x:Name="ItemsHost" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsExpanded" Value="false">
              <Setter Property="Visibility" Value="Collapsed" TargetName="ItemsHost" />
            </Trigger>
            <Trigger Property="HasItems" Value="false">
              <Setter Property="Visibility" Value="Hidden" TargetName="Expander" />
            </Trigger>
            <Trigger Property="IsSelected" Value="true">
              <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource SelectedOff}" x:Name="SelectedOn_BeginStoryboard1"/>
              </Trigger.ExitActions>
              <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource SelectedOn}" x:Name="SelectedOn_BeginStoryboard"/>
              </Trigger.EnterActions>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsSelected" Value="true" />
                <Condition Property="IsSelectionActive" Value="false" />
              </MultiTrigger.Conditions>
              <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
              <Setter Property="Background" TargetName="Selection_Border" Value="{DynamicResource SelectedBackgroundBrush}" />
              <Setter Property="Opacity" TargetName="Selection_Border" Value="0.5" />
              <Setter Property="BorderBrush" TargetName="Selection_Border" Value="{DynamicResource NormalBorderBrush}" />
            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard"/>
              </MultiTrigger.ExitActions>
              <MultiTrigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
              </MultiTrigger.EnterActions>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" SourceName="Selection_Border" Value="True" />
                <Condition Property="IsSelected" Value="False" />
              </MultiTrigger.Conditions>
            </MultiTrigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsSelected" Value="true" />
                <Condition Property="IsMouseOver" Value="true" SourceName="Selection_Border" />
              </MultiTrigger.Conditions>
              <Setter Property="Background" TargetName="Selection_Border" Value="{DynamicResource SelectedBackgroundBrush}" />
              <Setter Property="Opacity" TargetName="Selection_Border" Value="0.8" />
              <Setter Property="BorderBrush" TargetName="Selection_Border" Value="{DynamicResource NormalBorderBrush}" />
            </MultiTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- End of TreeViewItem -->

</ResourceDictionary>
